package com.xindacloud.sms.console.system.controller;


import com.xindacloud.sms.console.result.Result;
import com.xindacloud.sms.console.result.ResultGenerator;
import com.xindacloud.sms.console.system.dto.SmsAgentDTO;
import com.xindacloud.sms.console.system.dto.SmsAgentGroupDTO;
import com.xindacloud.sms.console.system.entity.SmsAgentGroup;
import com.xindacloud.sms.console.system.service.ISmsAgentGroupService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@Api(tags = {"短信通道组接口模块"})
@RestController
@RequestMapping("/api/v1/sms-agent-group")
public class SmsAgentGroupController {

    @Autowired
    private ISmsAgentGroupService agentGroupService;

    @ApiOperation(value = "添加短信通道组", response = SmsAgentGroup.class)
    @PostMapping("")
    public Result addSmsAgentGroup(@ApiParam(value = "添加短信通道组DTO", name = "smsAgentGroupDTO")
                                   @RequestBody SmsAgentGroupDTO smsAgentGroupDTO) {
        return ResultGenerator.genSuccessResult(agentGroupService.saveSmsAgentGroup(smsAgentGroupDTO));
    }


    @ApiOperation(value = "是否禁用通道组", response = Boolean.class)
    @PutMapping("/groupId/{groupId}/status/{status}")
    public Result disableGroup(@ApiParam(value = "groupId", name = "groupId", required = true)
                               @PathVariable(value = "groupId", name = "groupId") String groupId,
                               @ApiParam(value = "状态true为启用,false为禁用", name = "status", required = true,allowableValues = "true,false")
                               @PathVariable(value = "status", name = "status") Boolean status) {

        return ResultGenerator.genSuccessResult(agentGroupService.updateAgentGroupStatus(groupId, status));
    }

    @ApiOperation(value = "查询所有短信通道组列表", response = SmsAgentGroup.class)
    @GetMapping("")
    public Result querySmsAgentGroup() {
        return ResultGenerator.genSuccessResult(agentGroupService.querySmsAgentGroupList());
    }
    
    @ApiOperation(value = "删除短信平台组")
    @PostMapping("/deleteAgentGroups")
    public Result deleteAgentGroups(@ApiParam(value = "短信平台DTO", name = "smsAgentGroupDTO")
                           @RequestBody SmsAgentGroupDTO smsAgentGroupDTO) {
        return agentGroupService.deleteAgentGroups(smsAgentGroupDTO);
    }

}
